package cn.cs.controller;

import cn.cs.common.Dto;
import cn.cs.common.DtoUtil;
import cn.cs.service.AgentHandleComplaintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/cs_user")
public class AgentHandleComplaintController {
    @Autowired
    private AgentHandleComplaintService service;
    /****
     * 获取所有用户的投诉（根据状态）
     * @param
     * @param
     * @return
     */
    @RequestMapping("/complaintLsit")
    @ResponseBody
    public Dto complaintLsit(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=service.complaintLsit(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("查询失败","002");
        }
        return dto;
    }


    /****
     * 获取投诉数量
     * @param
     * @param
     * @return
     */
    @RequestMapping("/complaintCount")
    @ResponseBody
    public Dto complaintCount(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=service.complaintCount(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("查询失败","002");
        }
        return dto;
    }


    /****
     * 获取投诉详细信息
     * @param
     * @param
     * @return
     */
    @RequestMapping("/getComplaintInfo")
    @ResponseBody
    public Dto getComplaintInfo(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=service.getComplaintInfo(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("查询失败","002");
        }
        return dto;
    }

    /****
     * 获取投诉详细信息
     * @param
     * @param
     * @return
     */
    @RequestMapping("/handleComplaint")
    @ResponseBody
    public Dto handleComplaint(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=service.handleComplaint(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("查询失败","002");
        }
        return dto;
    }
}
